package com.kws.merchant.mapper;

import com.kws.merchant.domain.OperationDevice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kws.merchant.domain.vo.OperationDeviceVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 运维-设备台账(OperationDevice)表数据库访问层
 *
 * @author yxy
 * @since 2024-10-25 09:17:53
 */
@Mapper
public interface OperationDeviceMapper extends BaseMapper<OperationDevice> {


    @Select("select de.id as deviceId,it.id as itemId,sp.id as specificationId,de.`code`,de.`name`,de.type,it.item_name,sp.specification_model,op.`status`,op.principal,op.principal_phone,op.installation_site from tb_operation_device op left join tb_device de on op.device_id=de.id left join tb_specification sp on de.specification=sp.id left join tb_item it on op.item_id=it.id  where 1=1 ${sql} limit ${pageSize},${totalPage};")
    List<OperationDeviceVo> pageList(@Param("sql") String sql,@Param("pageSize") Integer pageSize,@Param("totalPage") Integer totalPage);

    @Select("select count(*) from tb_operation_device op left join tb_device de on op.device_id=de.id left join tb_specification sp on de.specification=sp.id left join tb_item it on op.item_id=it.id  where 1=1 ${sql};")
    Integer count(@Param("sql") String sql);
}
